const express=require('express');
const router=express.Router();
const db=require('../utils/db');
const jwt=require('jsonwebtoken');


router.post('/login',(req,res)=>{
    const {name,password}=req.body;
    if(name==='aaa' && password ==='111'){
        //学生
        res.json({data:{
            power:[
                {'path':'/home/student',icon:'UserFilled',title:'学生管理',component:"StudentView",btn:[]}
            ],
            token:123,
            user:{name:'aaa',password:111,id:1,tel:123}
        },msg:"登录成功"})
    }else if(name==='bbb' && password ==='222'){
        res.json({data:{
            power:[
                {'path':'/home/student',icon:'UserFilled',title:'学生管理',component:"StudentView",btn:['add','edit']},
                {'path':'/home/teacher',icon:'Avatar',title:'教师管理',component:"TeacherView"}
            ],
            token:123,
            user:{name:'bbb',password:'222',id:2,tel:123}
        },msg:"登录成功"})

    }else if(name==='ccc' && password ==='333'){
        res.json({data:{
            power:[
                {'path':'/home/student',icon:'UserFilled',title:'学生管理',component:"StudentView"},
                {'path':'/home/teacher',icon:'Avatar',title:'教师管理',component:"TeacherView"},
                {'path':'/home/admin',icon:'User',title:'管理员管理',component:"adminView"}
            ],
            token:123,
            user:{name:'ccc',password:'333',id:3,tel:123}
        },msg:"登录成功"})
    }else{
        res.json({msg:"账号或者密码错误"})
    }
    
})

module.exports=router;